package com.easy.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.easy.common.bean.SysPermission;
import com.easy.common.bean.SysRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RoleMapper extends BaseMapper<SysRole> {
    /**
     * 删除角色和权限的关联关系
     * @param roleId 角色 ID
     */
    void deleteRolePermissionRelations(@Param("roleId") Integer roleId);

    /**
     * 插入角色和权限的关联关系
     * @param roleId 角色 ID
     * @param permissionId 权限 ID
     */
    void insertRolePermissionRelation(@Param("roleId") Integer roleId, @Param("permissionId") Integer permissionId);
    @Select("select * from sys_permission where id in (select permission_id from sys_role_permission where role_id=#{id})")
    List<SysPermission> getPermissionsByRoleID(@Param("id")Integer roleid);
}
